package org.dftproject.genesis.ui.pages.summary.sources;

import org.dftproject.genesis.ui.figures.IHyperlinkListener;
import org.dftproject.genesis.ui.figures.TooltipLabel;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.StackLayout;
import org.eclipse.draw2d.text.FlowPage;
import org.eclipse.draw2d.text.ParagraphTextLayout;
import org.eclipse.draw2d.text.TextFlow;

public class FootnoteText extends Figure {
	
	private final FlowPage flowPage;
	
	public FootnoteText() {
		setLayoutManager(new StackLayout());
		
		flowPage = new FlowPage();
		add(flowPage);
	}
	
	public void addText(String text) {
		TextFlow textFlow = new TextFlow(text);
		textFlow.setLayoutManager(new ParagraphTextLayout(textFlow, ParagraphTextLayout.WORD_WRAP_SOFT));
		flowPage.add(textFlow);
	}

	public void addHyperlink(String text, IHyperlinkListener listener) {
		HyperlinkFlow hyperlink = new HyperlinkFlow(text);
		hyperlink.addHyperlinkListener(listener);
		hyperlink.setLayoutManager(new ParagraphTextLayout(hyperlink, ParagraphTextLayout.WORD_WRAP_SOFT));
		flowPage.add(hyperlink);
	}

	public void addHyperlink(String text, IHyperlinkListener listener, String tooltip) {
		HyperlinkFlow hyperlink = new HyperlinkFlow(text);
		hyperlink.setToolTip(new TooltipLabel(tooltip));
		hyperlink.addHyperlinkListener(listener);
		hyperlink.setLayoutManager(new ParagraphTextLayout(hyperlink, ParagraphTextLayout.WORD_WRAP_SOFT));
		flowPage.add(hyperlink);
	}
		
}